﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAccess.Partner;
using FOModels.Partner;
using System.Data;
namespace Bussiness.Partner
{
    public class PartnerBLL
    {
        private PartnerDAL dal;
        public PartnerBLL()
        {
            dal = new PartnerDAL();
        }

        public List<PartnerGroup> getPartnerGroupList()
        {
            List<PartnerGroup> list = new List<PartnerGroup>();
            PartnerGroup fur;
            DataTable tb = dal.getPartnerGroup();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerGroup();
                    fur.PartnerGroupID = int.Parse(row[0].ToString());
                    fur.PartnerGroupName = row[1].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<PartnerModels> getPartnerList()
        {
            List<PartnerModels> list = new List<PartnerModels>();
            PartnerModels fur;
            DataTable tb = dal.getPartnerList();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerModels();
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<PartnerModels> getPartnerListJson()
        {
            List<PartnerModels> list = new List<PartnerModels>();
            PartnerModels fur;
            DataTable tb = dal.getPartnerListJson();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerModels();
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                    fur.PartnerGroupName = row[6].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<PartnerModels> getPartnerListByGroupID(int groupid)
        {
            List<PartnerModels> list = new List<PartnerModels>();
            PartnerModels fur;
            DataTable tb = dal.getPartnerByGroupID(groupid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerModels();
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }

        public PartnerGroup getPartnerGroupByGroupID(int groupid)
        {
            PartnerGroup fur = new PartnerGroup();
            DataTable tb = dal.getPartnerGroupByGroupID(groupid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.PartnerGroupID = int.Parse(row[0].ToString());
                    fur.PartnerGroupName = row[1].ToString();
                }
            }
            return fur;
        }
        public PartnerModels getPartnerByID(int id)
        {
            PartnerModels fur = new PartnerModels();
            DataTable tb = dal.getPartnerByID(id);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                }
            }
            return fur;
        }
        public int UpdatePartnerGroup(PartnerGroup models)
        {
            if (dal.UpdatePartnerGroup(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertPartnerGroup(PartnerGroup models)
        {
            if (dal.InsertPartnerGroup(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public int DeletePartnerGroup(int ParterGroupID)
        {
            if (dal.DeletePartnerGroup(ParterGroupID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public int UpdatePartner(PartnerModels models)
        {
            if (dal.UpdatePartner(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertPartner(PartnerModels models)
        {
            if (dal.InsertPartner(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public int DeletePartner(int PartnerID)
        {
            if (dal.DeletePartner(PartnerID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        //EN

        public List<PartnerGroup> getPartnerGroupList_EN()
        {
            List<PartnerGroup> list = new List<PartnerGroup>();
            PartnerGroup fur;
            DataTable tb = dal.getPartnerGroup_EN();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerGroup();
                    fur.PartnerGroupID = int.Parse(row[0].ToString());
                    fur.PartnerGroupName = row[1].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<PartnerModels> getPartnerList_EN()
        {
            List<PartnerModels> list = new List<PartnerModels>();
            PartnerModels fur;
            DataTable tb = dal.getPartnerList_EN();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerModels();
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<PartnerModels> getPartnerListJson_EN()
        {
            List<PartnerModels> list = new List<PartnerModels>();
            PartnerModels fur;
            DataTable tb = dal.getPartnerListJson_EN();
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerModels();
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                    fur.PartnerGroupName = row[6].ToString();
                    list.Add(fur);
                }
            }
            return list;
        }
        public List<PartnerModels> getPartnerListByGroupID_EN(int groupid)
        {
            List<PartnerModels> list = new List<PartnerModels>();
            PartnerModels fur;
            DataTable tb = dal.getPartnerByGroupID_EN(groupid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur = new PartnerModels();
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                    list.Add(fur);
                }
            }
            return list;
        }

        public PartnerGroup getPartnerGroupByGroupID_EN(int groupid)
        {
            PartnerGroup fur = new PartnerGroup();
            DataTable tb = dal.getPartnerGroupByGroupID(groupid);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.PartnerGroupID = int.Parse(row[0].ToString());
                    fur.PartnerGroupName = row[1].ToString();
                }
            }
            return fur;
        }
        public PartnerModels getPartnerByID_EN(int id)
        {
            PartnerModels fur = new PartnerModels();
            DataTable tb = dal.getPartnerByID_EN(id);
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow row in tb.Rows)
                {
                    fur.PartnerID = int.Parse(row[0].ToString());
                    fur.PartnerName = row[1].ToString();
                    fur.PartnerImg = row[2].ToString();
                    fur.PartnerUrl = row[3].ToString();
                    fur.PartnerGroupID = int.Parse(row[4].ToString());
                }
            }
            return fur;
        }
        public int UpdatePartnerGroup_EN(PartnerGroup models)
        {
            if (dal.UpdatePartnerGroup_EN(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertPartnerGroup_EN(PartnerGroup models)
        {
            if (dal.InsertPartnerGroup(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public int DeletePartnerGroup_EN(int ParterGroupID)
        {
            if (dal.DeletePartnerGroup_EN(ParterGroupID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public int UpdatePartner_EN(PartnerModels models)
        {
            if (dal.UpdatePartner_EN(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
        public int InsertPartner_EN(PartnerModels models)
        {
            if (dal.InsertPartner_EN(models) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }

        public int DeletePartner_EN(int PartnerID)
        {
            if (dal.DeletePartner_EN(PartnerID) > 0)
            {
                return 1;
            }
            else
            {
                return -1;
            }
        }
    }
}
